home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / FILES.SWG / 0021_Get size of file.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-18  |  989b  |  34 lines

  1. { Gets size of existing file, in bytes.
  2.   Part of the Heartware Toolkit v2.00 (HTfile.PAS) for Turbo Pascal.
  3.   Author: Jose Almeida. P.O.Box 4185. 1504 Lisboa Codex. Portugal.
  4.           I can also be reached at RIME network, site ->TIB or #5314.
  5.   Feel completely free to use this source code in any way you want, and, if
  6.   you do, please don't forget to mention my name, and, give me and Swag the
  7.   proper credits. }
  8.  
  9. PROCEDURE Get_File_Size(FName : string;
  10.                     var FSize : longint;
  11.                     var Error : word);
  12. { DESCRIPTION:
  13.     Gets size of existing file, in bytes.
  14.   SAMPLE CALL:
  15.     Get_File_Size('C:\COMMAND.COM',FSize,Error);
  16.   RETURNS:
  17.     FSize : 0 if error
  18.             else file size
  19.     Error : DosError code }
  20.  
  21. var
  22.   SR    : SearchRec;
  23.  
  24. BEGIN { Get_File_Size }
  25.   {$I-}
  26.   FindFirst(FName,Archive,SR);
  27.   Error := DosError;
  28.   {$I+}
  29.   if Error = 0 then
  30.     FSize := SR.Size
  31.   else
  32.     FSize := 0;
  33. END; { Get_File_Size }
  34.